home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14527 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: sydney.DIALix.oz.au!not-for-mail
  2. From: jussi@sydney.DIALix.oz.au (Jussi Jumppanen)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help Please
  5. Date: 31 Mar 1996 21:02:15 +1000
  6. Organization: DIALix Services, Sydney, Australia.
  7. Sender: jussi@sydney.DIALix.oz.au
  8. Message-ID: <4jlonn$qa6$1@sydney.DIALix.oz.au>
  9. References: <4ji7eo$kgm@daisy.flex.com.au>
  10. NNTP-Posting-Host: jussi@sydney.dialix.oz.au
  11.  
  12. Tony L (cobweb@flex.com.au) wrote:
  13. : Hi all,
  14. : I have this prog that I can't get to do a simple IF condition
  15. : properly.  I just want it to say "You have voted for Paul Keating" if
  16. : the user enters Paul Keating.  Yeah!  I know, stupid idea for a
  17. : program  :-))) 
  18. : When I enter Paul Keating or not, it says "You didn't vote for Paul
  19. : Keating" even if I did enter "Paul Keating"
  20. : Could someone please help me with it....
  21. :     char first[15], last[15];
  22. :     char first2[15], last2[15];
  23. : lots removed.......
  24. :
  25. :     printf("\nWhat is their last name please? ");
  26. :     scanf("  %s", last2);
  27. :     if (last2 == him)
  28. :         { printf("you have voted for Paul Keating!"); }
  29. :     else
  30. :     { printf("\nYou didn't vote for Paul Keating!");  }
  31.  
  32. The problem is in the line 
  33.       if (last2 == him)
  34.  
  35. These are strings and can not be check for equality using this method
  36. You need to us the strcmp() or the stricmp() functions.
  37.  
  38. /-----------------------------------------------------------------------/
  39. /- Jussi Jumppanen (jussi@sydney.dialix.oz.au)                         -/
  40. /-----------------------------------------------------------------------/
  41. /- Author of: Zeus for Windows, Win32 (Brief, WordStar Clone) Editor   -/
  42. /-      garbo.uwasa.fi  :/windows/editor/zeusv200.zip                  -/
  43. /-      SimTel.Coast.NET:/SimTel/nt/editor/ze32v200.zip                -/
  44. /-      SimTel.Coast.NET:/SimTel/win3/editor/zeusv200.zip              -/
  45. /-      http://www.coast.net/SimTel/SimTel/win3/editor/zeusv200.zip    -/
  46. /-----------------------------------------------------------------------/
  47.  
  48.  
  49.